package com.zyong.design.pattern.visitor.case1;

import java.util.List;
import java.util.ArrayList;

/**
 * @program: zyong-design-pattern
 * @ClassName: ObjectStructure
 * @author: zyong
 * @create: 2024-03-28 23:28
 */
public class ObjectStructure {
    private List<Element> elements;

    public ObjectStructure() {
        elements = new ArrayList<Element>();
    }

    public void addElement(Element element) {
        elements.add(element);
    }

    public void accept(Visitor visitor) {
        for (Element element : elements) {
            element.accept(visitor);
        }
    }
}
